﻿using FluentAssertions;

using NewModel.Accounting.Calculation;
using NewModel.UnitTests.Accounting.Persistence._Samples_;

using NUnit.Framework;

namespace NewModel.UnitTests.Accounting.Calculation
{
    [TestFixture]
    public sealed class TestInterval
    {
        [Test]
        public void Equality_Should_Work()
        {
            Intervals.Monday.Should().Be(Intervals.Monday);
        }
        [Test]
        public void Intersect_Should_Return_Dates_Both_Intervals_Have_In_Common()
        {
            Intervals.Week.Intersect(Intervals.July).Should()
                .Be(new Interval(Dates.Saturday, Dates.NextMonday));
        }
        [Test]
        public void Intersect_When_No_Common_Points_Should_Return_Null()
        {
            Intervals.June.Intersect(Intervals.July).Should().BeNull();
        }
        [Test]
        public void Contains_Should_Check_Whether_Interval_Includes_Date()
        {
            Intervals.June.Contains(Dates.Monday).Should().BeTrue();
        }
        [Test]
        public void Contains_When_Out_Of_Interval_Should_Return_False()
        {
            Intervals.June.Contains(Dates.FirstDayOfSeptember).Should().BeFalse();
        }
        [Test]
        public void Contains_Should_Be_Left_Closed()
        {
            Intervals.June.Contains(Dates.FirstDayOfJune).Should().BeTrue();
        }
        [Test]
        public void Contains_Should_Be_Right_Open()
        {
            Intervals.June.Contains(Dates.FirstDayOfJuly.AddMilliseconds(-1))
                .Should().BeTrue();
            Intervals.June.Contains(Dates.FirstDayOfJuly).Should().BeFalse();
        }
    }
}